using System;
using System.Collections.Generic;

namespace NLite.Mini.Context
{
    /// <summary>
    /// 
    /// </summary>
    [Serializable]
    public class PreCreationContext : IPreCreationContext
    {
        /// <summary>
        /// 
        /// </summary>
        public IKernel Kernel { get; private set; }

        /// <summary>
        /// 
        /// </summary>
        public IComponentInfo Component { get; internal set; }

        /// <summary>
        /// 
        /// </summary>
        public IDictionary<string, object> NamedArgs { get; private set; }

        /// <summary>
        /// 
        /// </summary>
        public object[] Args { get; private set; }

        /// <summary>
        /// 
        /// </summary>
        public Type[] GenericParameters { get; internal set; }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="kernel"></param>
        /// <param name="gernericParameters"></param>
        public PreCreationContext(IKernel kernel, Type[] gernericParameters)
        {
            Kernel = kernel;
            GenericParameters = gernericParameters;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public IPreCreationContext Init(IComponentInfo info)
        {
            Component = info;
            
            return this;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="kernel"></param>
        /// <param name="info"></param>
        /// <param name="args"></param>
        /// <param name="genericParameters"></param>
        public PreCreationContext(IKernel kernel, IComponentInfo info, IDictionary<string, object> args, Type[] genericParameters)
        {
            Kernel = kernel;
            Component = info;
            NamedArgs = args;
            GenericParameters = genericParameters;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="kernel"></param>
        /// <param name="info"></param>
        /// <param name="args"></param>
        /// <param name="genericParameters"></param>
        public PreCreationContext(IKernel kernel, IComponentInfo info, object[] args, Type[] genericParameters)
        {
            Kernel = kernel;
            Component = info;
            Args = args;
            GenericParameters = genericParameters;
        }
    }
}
